# 使用前请将编译器路径放到环境变量
# 用法
# mingw32-make # 默认模式编译
# mingw32-make debug=1 # debug模式编译
# mingw32-make clean # 清理所有文件
# mingw32-make clean all # 清理所有文件然后默认模式编译
# mingw32-make clean all debug=1 #清理所有文件然后debug模式编译
# 然后输入bench.exe或者bench_debug.exe运行

cxx = g++
cxxflags = -c
src = bench.cpp sampleentropy.cpp
objdir = ./obj/
obj = $(patsubst %.cpp, $(objdir)%.o, $(src))
exe = bench.exe

ifeq ($(debug),1)
	cxxflags += -g
	obj := $(patsubst %.o, %_debug.o, $(obj))
	exe := bench_debug.exe
else
	cxxflags += -O3
endif

all: check $(exe)

$(exe): $(obj)
	$(cxx) -o $@ $^

$(objdir)%.o: %.cpp
	$(cxx) -o $@ $(cxxflags) $<

$(objdir)%_debug.o: %.cpp
	$(cxx) -o $@ $(cxxflags) $<

check:
	@ if not exist obj md obj

clean:
	@ del obj\*.o *.exe
